$(function () {
    $('#learn').on('click', function (event) {
        $('#learn').addClass('loading');
        var ids = ['e', 'n', 'h'];
        $.each(ids, function (index, value) {
            $('#' + value).val('');
        });
        event.stopPropagation();
        $.get(window.location.href + '/survey')
            .done(function (data) {
                $('#learn').removeClass('loading');
                $.each(ids, function (index, value) {
                    $('#' + value).val(data ? data[value].toFixed(4) : '失败');
                });
            }).
            fail(function (para) {
                $('#learn').removeClass('loading');
                $.each(ids, function (index, value) {
                    $('#' + value).val('失败');
                });
                alert('串口未经测试!')
            });
    });
});